package com.lin.app.midtermtest.jo6num3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class LINMidtermTestJo6Num3 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        init();
        
    }
    private void init(){
    	myWeb = (Button)findViewById(R.id.MyWeb);
    	myContacts = (Button)findViewById(R.id.MyContacts);
    	etMyWeb = (EditText)findViewById(R.id.et_myweb);
    	etMyContacts = (EditText)findViewById(R.id.et_mycontacts);
    	
    	myWeb.setOnClickListener(new OnClickListener(){

			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				String action = "com.lin63.web";
				Intent intent = new Intent(action);
				LINMidtermTestJo6Num3.this.startActivityForResult(intent,MYWEB);
			}});
    	myContacts.setOnClickListener(new OnClickListener(){

			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				String action = "com.lin63.con";
				Intent intent = new Intent(action);
				LINMidtermTestJo6Num3.this.startActivityForResult(intent,MYCON);
			}});
    }
    
    protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    	
    	if(resultCode == RESULT_OK){
    		Bundle b = data.getExtras();
    		if(requestCode==MYWEB){
    			etMyWeb.setText(b.getString(MYWEB_TAG));
    		}else if(requestCode==MYCON){
    			etMyContacts.setText(b.getString(MYCON_TAG));
    		}
    	}
    }
	
    public final static String  MYWEB_TAG = "MYWEB";

    public final static String  MYCON_TAG = "MYCON";
    private int MYWEB =1;
    private int MYCON =2;
    private Button myWeb,myContacts;
    private EditText etMyWeb,etMyContacts;
   
}